<template>
	<view>
		<view class="top">红包领取</view>
		<view style="margin-left: 20rpx;margin-top: 15rpx;">
			<u-line color="red" length="30%"></u-line>
		</view>
		<view class="top1">我的余额：<span style="color: red;">￥{{infor.balance}}元</span></view>
		<view class="input" v-if="!show1">
			<view class="top1" style="float: left;">提现金额：</view>
			<view style="width: 700rpx;margin-top: 20rpx;">
				<u--input placeholder="请输入提现金额" border="surround" v-model="value" @change="change"></u--input>
			</view>
		</view>
		<!-- <view style="width:500rpx;margin-left: 125rpx;" v-if="parseFloat(value) < parseFloat(sys.tx_min_price)">
			<view style="color: red;font-size: 30rpx;margin: 30rpx 0 0 20rpx;">
				最低领取金额为{{sys.tx_min_price}}元，未达到领取金额，请继续浇水积累红包金额！</view>
		</view>
		<view style="width:500rpx;margin-left: 125rpx;" v-if="parseFloat(value) >  parseFloat(infor.balance)">
			<view style="color: red;font-size: 25rpx;margin: 30rpx 0 0 20rpx;">余额不足</view>
		</view> -->
		<!-- v-if="value !='' && parseFloat(value) >= parseFloat(sys.tx_min_price) && parseFloat(value) <=  parseFloat(infor.balance)" -->
		<view class="button">
			<u-button @click="get_packget" type="primary" shape="circle" text="点击领取"></u-button>
		</view>
		<u-loading-page :loading="show1" loading-text="提交中..." loadingColor="#e8e8e8"></u-loading-page>
		<u-popup :show="show" mode="center" @close="close" @open="open" closeable="true">
			<image v-if="infor1.qrcode" :src="get_img+infor1.qrcode" class="jphx_img"></image>
			<view style="margin-left: 100rpx;">
				<text>请扫码核销</text>
			</view>
		</u-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				get_img: this.$get_img,
				value: '',
				disabled: true,
				sys: {},
				infor: {},
				infor1: {},
				show: false,
				show1: false
			}
		},
		onLoad() {
			
			this.sys = uni.getStorageSync("sys")
			this.infor = uni.getStorageSync("infor")
			console.log("get_price:",this.sys.tx_min_price)
		},
		methods: {
			get_packget() {
				this.show1 = false
				if (parseFloat(this.value) < parseFloat(this.sys.tx_min_price)) {
				
					uni.showModal({
						title: "最低领取金额为" + this.sys.tx_min_price + "元，如未达到领取金额，请继续浇水积累红包金额！",
					    showCancel:false
					});
					return
				} else if (parseFloat(this.value) > parseFloat(this.infor.balance)) {
					uni.showModal({
						title: '余额不足',
						 showCancel:false
					});
					return
				}
				
				this.show1 = true
				let that = this
				this.$model.get("user/create_tx_qrcode?price=" + this.value).then(res => {
					if (res.code == 200) {
						that.infor1 = res.data
						that.show1 = false
						that.show = true
					}
				})

			},
			change(e) {
				console.log('change', e);
			},
			// hx_packet(){
			// 	this.show = true
			// },
			open() {
			},
			close() {
				this.show = false
			}
		}
	}
</script>

<style>
	.top {
		/* text-align: center; */
		margin: 30rpx 0 0 50rpx;
		font-weight: 600;
		color: red;
	}

	.top1 {
		/* text-align: center; */
		margin: 30rpx 0 0 50rpx;
		font-weight: 600;

	}

	.input {
		height: 70rpx;
		width: 750rpx;
		margin-top: 40rpx;

	}

	.button {
		height: 70rpx;
		width: 600rpx;
		margin: 40rpx 0 0 75rpx;
	}

	.jphx_img {
		width: 400rpx;
		height: 400rpx;
	}
</style>
